#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <strings.h>
#include <unistd.h>

#define DEV_LCD "/dev/fb0"
#define BUFF_SIZE 800*480*4

int main(int argc, char **argv){
	
	int fd_lcd = open(DEV_LCD, O_RDWR);
	if (fd_lcd == -1){
		printf("Opening LCD failed.\n");
		exit(-1);
	}
	
	//prepare pixel color
	int color = 0x00006666;
	
	//map memory
	int *plcd_map = mmap(NULL, BUFF_SIZE/4, PROT_READ|PROT_WRITE, MAP_SHARED, fd_lcd, 0);
	if (plcd_map == MAP_FAILED) {
		printf("Mapping LCD to memory failed.\n");
		exit(-1);
	}
	
	//display
	for (int i=0; i<BUFF_SIZE/4; i++){
		*(plcd_map) = color;
	}
	
	//unmap
	munmap(plcd_map, BUFF_SIZE);
	close(fd_lcd);
	
	return 0;
}

